<template>
  <div  class="elm-list-edit infolist">


    <div style="width:73%; margin:14px auto;padding-top: 92px;padding-bottom: 20px;
  background-color: #ffffff; border-radius: 4px; opacity:0.9;
  min-height: calc(100vh - 150px);position: relative"
         :style="{backgroundImage: 'url(/res/ivew_background.svg)',backgroundSize:'100%',backgroundRepeat:'no-repeat'}">


      <div style="position: absolute;  left: 45px;
  right: 40px;
  top: 40px;
  bottom: 40px;">  <h2>{{
          $route.query.type=='notice'?'通知公告':
              ($route.query.type=='news'?'新闻动态':'阳明心学')}}</h2>
      </div>
<div style="position: absolute;  left: 40px;
  right: 40px;
  top: 100px;
  bottom: 40px;">

  <elm-page-tb  :splite="false" :splite-show="false" :top-show="false" height="0px">
  <template #top>
    <right>
      <el-button-group>
      </el-button-group>
    </right>
  </template>
    <elm-table v-if="$route.query.type=='notice'" url="/business/my/GetNoticeData"  style="max-width: 100%;margin-top: 10px;"  @row-click="openNotice" :show-index="false" :show-header="false" :post-data="postData" height="100%">
      <el-table-column prop="title" label="标题"  align="left">
        <template #default="{ row }">
          <div class="title-cell">{{ row.title }}</div>
        </template>
      </el-table-column>
      <el-table-column prop="publish_time" :formatter="formatDate" label="发布时间" width="120px"  align="center"></el-table-column>
    </elm-table>
    <elm-table v-else-if="$route.query.type=='news'" url="/business/my/GetNewsData"  style="max-width: 100%;margin-top: 10px;"  @row-click="openNews" :show-index="false" :show-header="false" :post-data="postData" height="100%">
      <el-table-column prop="title" label="标题"  align="left">
        <template #default="{ row }">
          <div class="title-cell">{{ row.title }}</div>
        </template>
      </el-table-column>
      <el-table-column prop="publish_time" :formatter="formatDate" label="发布时间" width="120px"  align="center"></el-table-column>
    </elm-table>
    <elm-table v-else-if="$route.query.type=='qywh'" url="/business/my/GetYmxxData"  style="max-width: 100%;margin-top: 10px;"  @row-click="openNews" :show-index="false" :show-header="false" :post-data="postData" height="100%">
      <el-table-column prop="title" label="标题"  align="left">
        <template #default="{ row }">
          <div class="title-cell">{{ row.title }}</div>
        </template>
      </el-table-column>
      <el-table-column prop="publish_time" :formatter="formatDate" label="发布时间" width="120px"  align="center"></el-table-column>
    </elm-table>
  </elm-page-tb>
</div>
    </div>
  </div>
</template>
<script>
export default {
  extends: elmVueBase,
  data() {
    return {
      model: {},
      module_name:null
    }
  },
  async created() {
  },
  methods: {
    async openNews(row, column, event)
    {
      window.open("/view/my/infoview?area=infoview&news="+row.id);
      var res= await elm.post('/business/my/GetNews',{id:row.id});
      await elm.post('/business/my/UpdateNewsViews',{id:row.id,views:res.views+1});
    },
    async openNotice(row, column, event)
    {
      window.open("/view/my/infoview?area=infoview&notice="+row.id);
      var res= await elm.post('/business/my/GetNotice',{id:row.id});
      await elm.post('/business/my/UpdateNoticeViews',{id:row.id,views:res.views+1});
    },
  }
}
</script>
<style>
.infolist .el-table--border, .infolist.el-table--group , .infolist .el-table td.el-table__cell{
  border: 0px solid #EBEEF5;
}
.infolist .el-table::before {
  display: none;
}
.infolist .el-table::after {
  display: none;
}
.infolist .el-table .cell
{
  cursor: pointer;
}

.elm-list-edit.infolist .elm-page-bottom {
  padding-top: 0px !important;
  min-height: 100% !important;
}

.infolist .el-table .cell
{
  cursor: pointer;
}

.infolist .title-cell {
  white-space: nowrap;      /* 防止换行 */
  overflow: hidden;         /* 隐藏溢出的文本 */
  text-overflow: ellipsis;  /* 显示省略号 */
  max-width: 100%;          /* 确保容器不会超出表格 */
}
</style>